package com.jeesite.modules.dept.web;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.dept.entity.Employees;
import com.jeesite.modules.dept.service.EmployeesService;

/**
 * dept_employeesController
 * @author ccz
 * @version 2025-03-20
 */
@Controller
@RequestMapping(value = "${adminPath}/dept/employees")
public class EmployeesController extends BaseController {

	@Autowired
	private EmployeesService employeesService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public Employees get(String id, boolean isNewRecord) {
		return employeesService.get(id, isNewRecord);
	}

	/**
	 * 管理主页
	 */
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = "index")
	public String index(Employees employees, Model model) {
		model.addAttribute("employees", employees);
		return "modules/dept/employeesIndex";
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = {"list", ""})
	public String list(Employees employees, Model model) {
		model.addAttribute("employees", employees);
		return "modules/dept/employeesList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<Employees> listData(Employees employees, HttpServletRequest request, HttpServletResponse response) {
		employees.setPage(new Page<>(request, response));
		Page<Employees> page = employeesService.findPage(employees);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = "form")
	public String form(Employees employees, Model model) {
		model.addAttribute("employees", employees);
		return "modules/dept/employeesForm";
	}

	/**
	 * 保存数据
	 */
	@RequiresPermissions("dept:employees:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated Employees employees) {
		employeesService.save(employees);
		return renderResult(Global.TRUE, text("保存员工信息表成功！"));
	}
	
	/**
	 * 删除数据
	 */
	@RequiresPermissions("dept:employees:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(Employees employees) {
		employeesService.delete(employees);
		return renderResult(Global.TRUE, text("删除员工信息表成功！"));
	}


	/**
	 * 查询column列表
	 */
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = {"listColumn", ""})
	public String listColumn(Employees employees, Model model) {
		model.addAttribute("employees", employees);
		return "modules/dept/Column";
	}

	/**
	 * 查询columndata列表数据
	 */
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = "listColumnData")
	@ResponseBody
	public List<Map<String, Object>> listColumnData() {
		List<Map<String, Object>> listColumnData = employeesService.listColumnData();
		return listColumnData;
	}


	/**
	 * 查询zhexain列表数据
	 */
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = "listZheXianData")
	@ResponseBody
	public List<Map<String, Object>> listZheXianData() {
		List<Map<String, Object>> page = employeesService.listZheXianData();
		return page;
	}




/*	*//**
	 * 查询列表
	 *//*
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = {"listByName"})
	public String listByName(@PathVariable(value = "nativePlace") String nativePlace, Model model) {
		System.out.println("----------------------------------------");
		model.addAttribute("nativePlace", nativePlace);
		return "modules/dept/employeesName";
	}

	*//**
	 * 查询列表数据
	 *//*
	@RequiresPermissions("dept:employees:view")
	@RequestMapping(value = "listByNameData")
	@ResponseBody
	public List<Map<String,Object>> listByNameData(String nativePlace) {
		System.out.println(nativePlace);

		List<Map<String,Object>> page = employeesService.findName(nativePlace);
		return page;
	}*/





}